import { Component, ViewChild, ElementRef, OnInit } from '@angular/core';

declare var AMap;

@Component({
  selector: 'app-amap',
  templateUrl: './amap.page.html',
  styleUrls: ['./amap.page.scss'],
})
export class AmapPage implements OnInit {

  @ViewChild('map_container', { static: false }) map_container: ElementRef;
  map: any;//地图对象
  center: any;
  constructor() {
  }

  ngOnInit() { }
  ionViewDidEnter() {
    this.map = new AMap.Map(this.map_container.nativeElement, {
      view: new AMap.View2D({//创建地图二维视口
        zoom: 11, //设置地图缩放级别
        rotateEnable: true,
        showBuildingBlock: true
      })
    });
    this.map.on("moveend", (e) => {
      this.logmapinfo();
    });
  }
  logmapinfo() {
    this.center = this.map.getCenter();
    alert(this.center);
  }

}
